class MAIN

inherit
	AC
	
creation
	make
	
feature

	rest (s: STRING; x: POINTER) is
		do
		    rest0(s.to_external,x)
		end -- rest

	rest0 (s: POINTER; x: POINTER) is
		external "C"
		end -- rest0
	
	
	
	make is 
		local
			b: ALVO_RUNTIME
			c: ALVO
		do
			!!b.make
			c := alvo_x(b)
			eval(b, c)
		
			--
			--~ if (0) {int fd=open("fib.alvo", O_RDONLY);
			--~ if (fd==-1) {return 999;};
			--~ char s[4096];
			--~ int bytes=read(fd,s,sizeof(s)-1);
			--~ s[4096]='\0';
			--~ assert(bytes>0);
			--~ int i=0;}
			--~ --AlvoP(s,i,*new SymStream);
			rest("fib.alvo", c)
			eval(b,c)
			--
			--return 0;
		end -- make


enter_frame (frame:ALVO_RUNTIME; lazy:A_LAZY) --ALVO_frame??
			is do
end


	eval (frame:ALVO_RUNTIME; i:ALVO --/*const*/ 
	): ALVO is 
		local
			gr: A_LAZY
			gr_int: A_INT
			gr_eval: A_EVAL
			error: INTEGER
			ii: ITERATOR[ALVO]
			dummy:ALVO
		do
	
			if (i.ac = AC_LAZY) then
				gr ?= i
				from 
					enter_frame(frame, gr)
					ii := gr.cursor
				until
					ii.is_off
				loop
					dummy:=eval(frame, ii.item)
					ii.next
				end
			elseif i.ac = AC_INTEGER then
				gr_int ?= i
				frame.push(gr_int)
			elseif i.ac = AC_EVAL then
				gr_eval ?= i
				frame.eval(gr_eval)
			else 
				--~ cout << "\nerror(32)" << i->ac << endl;
				--~ assert(32!=32);
				--throw 77;
				error:=100//0
			end
		end -- eval

	alvo_x(b:ALVO_RUNTIME ): ALVO  is 
		local
			a2: A_INT
			a3: A_EVAL
		do
			Result:=b.c.lazy
			a2:=b.c.int_(3, b.x.cont(Result))
			a3:=b.c.eval("print", b.x.cont(Result))
		end -- alvo_x

end -- class MAIN

